import { request } from '@pkg/request/src';
import {toTreeList} from '@pkg/utils';
export enum Api {
  page = '/html/pageList',
  all = '/html/all',
  list = '/html/list',
  get = '/html/get',
  add = '/html/save',
  update = '/html/update',
  remove = '/html/delete',
}
export const list = () => {
  return request.get({url: Api.all}, {errorMessageMode: 'none', successMessageMode: 'none'}).then((data) => {
    const opt = {primaryKey: 'htmlId', title: 'htmlTitle'};
    return toTreeList(data, opt, '0');
  });
}

export const add = (params) => {
  return request.post({url: Api.add, params: params}, {errorMessageMode: 'none'});
}

export const update = (params) =>
  request.post({url: Api.update, params: params}, {errorMessageMode: 'none'});

export const remove = (ids: string) =>
  request.post({url: Api.remove, params: {ids: ids}}, {errorMessageMode: 'none'});
